package com.swgk.core.view.pop;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.swgk.core.R;
import com.swgk.core.dialog.BaseBottomDialog;
import com.swgk.core.dialog.DialogViewHolder;
import com.swgk.core.recyclerview.adapter.PageRecycleAdapter;
import com.swgk.core.recyclerview.adapter.SeekingRentSecondPublishPopAdapter;
import com.swgk.core.recyclerview.entity.PublishMenuEntity;
import java.util.List;

/**
 * Time:2021/8/30
 * AUTHOR:F_Q
 * Description:
 */
public class HomeZhaoCaiPublishMenuPop  extends BaseBottomDialog {

    private RecyclerView rl_rv_menu;
    private TextView tv_cancel;
    private SeekingRentSecondPublishPopAdapter menuAdapter;
    private DialogClickCallBack dialogClickCallBack;

    public HomeZhaoCaiPublishMenuPop(Context context, DialogCallBack dialogCallBack) {
        super(context, dialogCallBack);
    }

    @Override
    protected int dialogLayout() {
        return R.layout.popwindow_lease_publish;
    }

    @Override
    protected void initView(DialogViewHolder holder, Bundle savedInstanceState) {
        rl_rv_menu = holder.getDialog().findViewById(R.id.rv_menu);
        tv_cancel = holder.getDialog().findViewById(R.id.img_close);
        menuAdapter = new SeekingRentSecondPublishPopAdapter(context, null);
        rl_rv_menu.setLayoutManager(new GridLayoutManager(context, 4));

        rl_rv_menu.setAdapter(menuAdapter);
        menuAdapter.setOnItemClick(new PageRecycleAdapter.OnItemClick<PublishMenuEntity>() {
            @Override
            public void onClick(PublishMenuEntity entity, int position) {
                dialogClickCallBack.onItemClick(entity.getName());
                dismiss();
            }
        });
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }
    public void setData(List<PublishMenuEntity> data) {
        menuAdapter.setDatas(data);
    }

    public interface DialogClickCallBack {
        void onItemClick(String name);
    }

    public HomeZhaoCaiPublishMenuPop setDialogClickCallBack(DialogClickCallBack dialogClickCallBack) {
        this.dialogClickCallBack = dialogClickCallBack;
       return this;
    }
}
